home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / tm480 / tmexam.exe / WORDPROC.TSK < prev   
Text File  |  1991-09-10  |  14KB  |  499 lines

  1. ; Title   : WORDPROC.TSK                Last Updated : August 28, 1991
  2. ; Author  : Steve Johnson - FmP.        Version      : 1.21
  3. ; Purpose : Remembers the names of up to 10 files with descriptions
  4. ;           and edit dates and times. Edits files with nominated editor.
  5. ; Notes   : Uses SAVE and RESTORE to/from WORDPROC.TM
  6. ; Latest 1.21
  7. ;         : Couldn't RUN editor or LIST from the root directory.
  8. ; Changes : Use of virtual menu facility for menu 1.
  9. ;         : Creates WORDPROC.TM in each directory invoked from
  10.  
  11. hexvar esc,1b
  12. int popid
  13. int selvar
  14. var selvars,7,' CERDV'          ;esc appended later!
  15. int count                       ;loop counter
  16. int cv,ev,line
  17. int resperror
  18. int savechoice
  19.  
  20. logical delete
  21. logical dontdraw
  22. logical edit
  23. logical editing
  24. logical forever
  25. logical located
  26. logical nodat
  27.  
  28. var action,8,'WORDPROC'
  29. var char,1
  30. var datf,12,"WORDPROC.TM"       ;Name of data file
  31. var datv,8,OCCURS 10            ;Edit times
  32. var descriptlist,30,occurs 10
  33. var dot_ext,4
  34. var editor,40
  35. var filelist,14,occurs 12,
  36. '                            '
  37. '                            '
  38. '                            '
  39. '                            '
  40. '                            '
  41. 'Update list   Quit wordproc '
  42.  
  43. var filename,14
  44. var lead,10                     ;Pars before filename
  45. var location,40
  46. var locn,7
  47. var message,58
  48. var name,40
  49. ;ar newfile,14,'Update list'
  50. var null,1
  51. var path,164,$path               ;set to environment variable path
  52. var root,3
  53. var select,1                    ;Holds key user presses when prompted
  54. var timv,8,occurs 10            ;Edit dates
  55. var trail,10                    ; ''  after  ''
  56. var tname,8,"WORDPROC"
  57. var try,40
  58. var work_dir,64
  59. vconst attn,79                  ;Clear screen
  60. vconst cel,55                   ;Clear line
  61. vconst cep,56                   ;Clear page
  62. vconst cls,11                   ;Clear screen
  63. vconst normal,5                 ;Reset colours
  64.  
  65. END
  66.  
  67. move true to hide
  68. lookfor wordproc.ovr
  69. if not found
  70.   forms logon.ovr       ;in case /q and registered
  71.   insert tname tname
  72.   put "NO_FORMS"
  73.   stop
  74. fi
  75. combine ddrive ':\' into root
  76. user work_dir
  77. if work_dir = root
  78.   sizevar work_dir 2
  79. fi
  80. forms wordproc.ovr              ;Open relevant forms file
  81. display cls
  82. dir datf                        ;Check for presence of datafile
  83. if found
  84.   restore datf datv timv filelist descriptlist editor lead trail name
  85.   if resp ne 0
  86.     wait "WORDPROC: Error during data restoration"
  87.     stop
  88.   fi
  89. else
  90. ; go to a label
  91.   move '1RETURN' to locn
  92.   goto 1INIT
  93. 1RETURN
  94.   if anyfk
  95.     stop
  96.   fi
  97. fi
  98. append esc to selvars
  99. until forever
  100.   if editing                    ;initially false
  101.     move 2 to line
  102.     clear count                   ;reset loop count
  103.     until count = 10
  104.       fieldfill entry count of filelist         ;fill a field of next form
  105.       fieldfill entry count of descriptlist     ;fill a field of next form
  106.       move entry count of filelist to filename  ;extract filename
  107.     fi count                            ;increment loop count
  108.     cursor 12 0 cep                     ;clear screen from line 12
  109.     put 'EDIT' noclear                  ;display fields for editing
  110.     cursor 12 0 cep                     ;clear screen from line 12 again
  111.     if not anyfk                        ;ignore if user pressed a function key
  112.       clear count                   ;reset loop count
  113.       until count = 10 or anyfk         ;loop 10 times
  114.     get entry count of filelist     ;get edited data from all fields
  115.     get entry count of descriptlist
  116.     if entry count of filelist = spaces and entry count of descriptlist ne spaces
  117.       clear entry count of descriptlist
  118.       add 2 to count giving line
  119.       cursor line 22 cel
  120.     fi
  121.       fi count
  122.       clear select
  123.     else
  124.       move "X" to select
  125.     fi
  126.   fi
  127.   if not dontdraw
  128.     clear count                       ;reset loop count
  129.     move 2 to line
  130.     until count = 10      ;display data, file statuses
  131.       move entry count of filelist to filename
  132.       if filename ne spaces
  133.         if select ne "R"
  134.       if not editing or anyfk 
  135.             fore 15
  136.         cursor line 22 entry count of descriptlist
  137.         if select ne 'X'
  138.           cursor line 54 entry count of datv
  139.           cursor line 63 entry count of timv
  140.         fi
  141.       fi
  142.       if select ne 'X'
  143.         trim filename
  144.         dir filename
  145.         if found
  146.           cursor line 72 "Present"
  147.         else
  148.           cursor line 72 "Absent "
  149.         fi
  150.       fi
  151.         fi
  152.       fi
  153.       increment line
  154.     fi count
  155.   fi
  156.   clear editing                         ;finished edit phase
  157.   move 0e000H to bbmask                 ;Enable F1, F2 and ESC keys
  158.   menu 2,'DISPLAY_LIST',filelist
  159.   option 2,12
  160.   option 2,30
  161.     save datf                           ;open file for output
  162.     move resp to resperror
  163.     save datv timv filelist descriptlist editor lead trail name
  164.     add resp to resperror
  165.     save                                ;close file
  166.     add resp to resperror
  167.     if resperror ne 0
  168.       wait 'WORDPROC: An error occured when attempting to save data'
  169.     fi
  170.     stop                                ;(or ESC) return to operating system
  171.   option 2,1,10
  172.     subtract 1 from choice giving count
  173.     move entry count of filelist to filename ;get appropriate filename
  174.     move choice to savechoice
  175.     clear choice
  176.     trim filename                     ;remove any trailing spaces
  177.     dir filename                      ;check for file..
  178.     move 8000h to bbmask
  179.     if found                          ;display appropriate option list
  180.       move ev to choice
  181.       put "EDIT_LIST"
  182.       move hilite to ev
  183.     else
  184.       move cv to choice
  185.       put "CREATE_LIST"
  186.       move hilite to cv
  187.     fi
  188.     if choice = 30
  189.       move esc to select
  190.     else
  191.       move display to select                    ;Use first char of Topic
  192.     fi
  193.     if selvars ct select
  194.       move fcol to selvar
  195.     fi
  196.     clear dontdraw
  197.     menu 1,selvar       ;this is a virtual menu - no template
  198.     option 1,1,2
  199.       cursor 13 20 cel                        ;clear message line
  200.       run editor 1 lead 1 work_dir '\' filename 1 trail    ;execute editor
  201.       display cls                             ;clear screen on exit
  202.       if elevel = 0
  203.         move time to entry count of timv     ; edit date
  204.         move date to entry count of datv     ;and time
  205.       else
  206.         wait 'WORDPROC: A problem occurred when attempting to run editor'
  207.         stop
  208.       fi
  209.       exitm
  210.     option 1,3
  211.     option 1,6
  212.       cursor 13 20 cel
  213.       clear bbdisp
  214.       move savechoice to choice  
  215.       put 'MM_MESSAGE' nowait
  216.       return 1
  217.     option 1,4
  218.       cursor 14 20 cel attn
  219.       ask delete 'Delete ' filename ': Are you sure? (enter Y or N)'
  220.       cursor 14 20 normal cel
  221.       if delete
  222.         erase filename
  223.       else
  224.         move true to dontdraw
  225.       fi
  226.       exitm
  227.     option 1,5
  228.       cursor 13 20 cel
  229.       popscreen popid
  230.       run 'list ' work_dir '\' filename
  231.       popdown popid
  232.       popfree popid
  233.       put 'MM_MESSAGE' nowait
  234.       clear popid
  235.       clear bbdisp
  236.       move true to dontdraw
  237.       exitm
  238.     endm 1
  239.     move savechoice to choice                 ;Destroyed by 2nd menu
  240.     exitm
  241.   option 2,31
  242.     put "HELP_SCREEN" wait 0 noclear
  243.     move "R" to select
  244.     move hilite to choice
  245.     clear bbdisp
  246.     exitm
  247.   option 2,32
  248.     append 40 to name
  249.     sizevar name 14
  250.     fieldfill NAME
  251.     move '1UPDATE' to locn
  252.     move 'CHANGES ' to action
  253.     goto 1INIT
  254.     clear choice
  255. 1UPDATE
  256.     exitm
  257.   option 2,11                      ;user wants to add a file
  258.     move true to editing
  259.   endm 2  
  260. fi
  261. 1INIT
  262. ;a label for a GOTO command
  263. clear dontdraw
  264. clear found message
  265. until found OR anyfk
  266. ; ask for a directory and program name
  267. ; combine the two add .exe if no '.' supplied
  268. ; then confirm the existence of that file
  269.   insert message action
  270.   put "EDITOR" noclear
  271.   if not anyfk
  272.     get name
  273.     trim name
  274.     if not name ct "."
  275.       append ".exe" to name
  276.     fi
  277.     verify name using count editor
  278.     setscan editor 2
  279.     move zero to delim
  280.     sizevar name 8
  281.     clear dot_ext
  282.     scan name dot_ext
  283.     trim name
  284.     append dot_ext to name
  285.     move name to editor
  286.     move editor to try
  287.     dir editor
  288.     if not found
  289.       setscan path
  290.       move ';' to delim
  291.       move true to found
  292.       clear located nodat
  293.       until located or nodat
  294.     clear location
  295.     scan location
  296.     if found
  297.       move location to try  ;lookout for trailing \
  298.       append "*" to try
  299.       if try ct "\*"
  300.         combine location editor into try
  301.       else
  302.         combine location '\' editor into try
  303.       fi
  304.       dir try
  305.       move found to located
  306.     else
  307.       move true to nodat
  308.     fi
  309.       fi
  310.       if not found
  311.     append 40 to editor
  312.     append 40 to name
  313.     sizevar name 14
  314.     combine "Unable to access: " editor into message
  315.     fieldfill name
  316.       else
  317.     move try to editor
  318.         clear message
  319.       fi
  320.     fi
  321.   fi
  322. fi
  323. if not anyfk
  324.   if locn = '1UPDATE'
  325.     fieldfill lead trail
  326.   fi
  327.   insert try action
  328.   put "PARAMETERS"
  329.   if not anyfk
  330.     get lead trail
  331.     trim lead trail
  332.     save datf                           ;open file for output
  333.     move resp to resperror
  334.     save datv timv filelist descriptlist editor lead trail name
  335.     add resp to resperror
  336.     save                                ;close file
  337.     add resp to resperror
  338.     if resperror ne 0
  339.       wait 'WORDPROC: An error occured when attempting to save data'
  340.       stop
  341.     fi
  342.   fi
  343. else
  344.   display normal cls
  345. fi
  346. ; go back to where you came from!
  347. GOBACK LOCN
  348.  
  349. ENDTASK         ;marks end of executive commands
  350.  
  351. @VID
  352. @nf DISPLAY_LIST
  353. @win line2,column2,depth10,width1
  354. @win line2,column17,depth10,width5
  355. @win line2,column52,depth10,width1
  356. @COL CHAR,WHITE,blue
  357. @win line0,column0,depth2,width0
  358. @COL char,blue,cyan
  359. @HEAD LEFT,'FmP Taskmaster Demo'
  360. @HEAD RIGHT,'Wordprocessing Helper'
  361. @HEAD CENTRE,'WORDPROC.TSK'
  362. @BANNER
  363. @COL CHAR,cyan,blue
  364.    Filename           Description                     Date     Time     Status
  365. @COL CHAR,cyan,black
  366. @win line2,column0,depth12,width16
  367. @BBMENU WHITE,BLUE
  368. @COL CHAR,WHITE,BLUE
  369. @repeat x12
  370.   {              }
  371.  
  372. @COL CHAR,WHITE,BLack
  373. @win line13,column20,depth1,width0
  374. @COL CHAR,WHITE,BLUE
  375. Press F1 for help. F2 to change editor details.
  376. @colour char,white,black
  377. @bright
  378. @END
  379. @nf mm_message
  380. @win line13,column20,depth1,width0
  381. @COL CHAR,WHITE,BLUE
  382. Press F1 for help. F2 to change editor details.
  383. @COL CHAR,WHITE,BLACK
  384. @bright
  385. @END
  386. @nf EDIT
  387. @OVERLAY
  388. @acceptfk f10
  389. @FILENAME
  390. @STR
  391. @FILENAME OPTIONAL
  392. @STR
  393. @FILENAME OPTIONAL
  394. @STR
  395. @FILENAME OPTIONAL
  396. @STR
  397. @FILENAME OPTIONAL
  398. @STR
  399. @FILENAME OPTIONAL
  400. @STR
  401. @FILENAME OPTIONAL
  402. @STR
  403. @FILENAME OPTIONAL
  404. @STR
  405. @FILENAME OPTIONAL
  406. @STR
  407. @FILENAME OPTIONAL
  408. @STR
  409. @window line2,column0,depth10,width50
  410. @repeat x10
  411.   [              ]   [                              ]
  412.  
  413. @col char,yellow,blue
  414. Use TAB and BACKTAB to move beween fields.
  415. When finished press  to save changes or F10 to abandon them.
  416. @colour char,white,black
  417. @bright
  418. @END
  419. @nf CREATE_LIST
  420. @window line 13,column20,depth1,width0
  421. @BBIMENU cyan,blue
  422. {Create New file }{Return to filelist }
  423. @colour char,white,black
  424. @bright
  425. @END
  426. @nf EDIT_LIST
  427. @window line 13,column20,depth1,width0
  428. @BBIMENU cyan,blue
  429. {Edit file }{View file }{Delete file }{Return to filelist }
  430. @colour char,white,black
  431. @bright
  432. @END
  433. @nf HELP_SCREEN
  434. @colour char,cyan,blue
  435. @window line 15,column0,depth9,width0
  436. @out cyan
  437.  
  438.   The UPDATE option allows you to define a list of filenames and  descriptions 
  439.   for files in the working directory. Taskmaster  checks to see if named files 
  440.   exist and displays the result of this check in the status column.   
  441.  
  442.   This  task demonstrates the flexibility of Taskmaster Bounce-bar  menus.  As 
  443.   you  see, the topics are not fixed; they can be defined and edited  at  Run-
  444.   Time.  The text of the selected topic can be used directly in the task.
  445. @colour char,white,black
  446. @bright
  447. @END
  448. @nf EDITOR
  449. @acceptfk f10
  450. @file
  451. @col page,cyan,blue
  452. @border
  453.  
  454.  
  455.                               Welcome to WORDPROC
  456.  
  457. @col char,cyan,blue
  458.      The file wordproc.tm is used to store the following information:
  459.      1. Details of your text editor,
  460.      2. The names, descriptions and edit DATES/TIMES of up to 10 files
  461.  
  462.      What  do you normally type to access your wordprocessor  or  text
  463.      editor ? If you use a COM or BAT extension please supply it  else
  464.      .EXE assumed. (Omit the drive letter)
  465.  
  466. @col char,white,blue
  467.      Editor name [            ] I will expect to find it on the PATH
  468.      {                                                          }
  469. @col char,cyan,blue
  470.      Press Function key F10 to abandon{WORDPROC} or  to continue.
  471. @col char,white,blue
  472. @bright
  473. @END
  474. @nf parameters
  475. @acceptfk f10
  476. @str
  477. @str
  478. @col char,cyan,blue
  479. @win line8,column1,depth10,width78
  480. @col char,white,blue
  481.     Your editor is: {                                        }
  482.  
  483. @col char,cyan,blue
  484.     When  I  edit a file I will pass the  filename   as   a   command
  485.     line  parameter;  if  you  would like  me  to  supply  additional
  486.     parameters before or after the filename please supply them now:
  487.  
  488. @col char,white,blue
  489.     editor [          ] filename [          ]
  490.            leading pars          trailing pars
  491.  
  492. @col char,cyan,blue
  493.      Press Function key F10 to abandon{WORDPROC} or  to continue.
  494. @col char,white,blue
  495. @bright
  496. @end
  497. @eof
  498.  
  499.